<?php

namespace App\Modules\Apicrzs\Services\System;

use App\Modules\Admin\Entities\System\FeedbackModel;
use App\Modules\Admin\Services\BaseService;
use App\Traits\CryptAES;
use Illuminate\Support\Facades\DB;

// 投诉反馈
class FeedbackService extends BaseService
{
    public function __construct(FeedbackModel $banner)
    {
        $this->model = $banner;
        $token =  \request()->header('token');
        $user_info = CryptAES::decryptToken($token,'user_grzq');
        $this->user_id = $user_info['data']['user_id']??"";

    }
    public function create(array $params)
    {
        if (empty($params['content'])){
            $this->error='内容不能为空';
            return false;
        }

        DB::beginTransaction();
        try{
            $params['user_id'] = $this->user_id;
            parent::create($params); // TODO: Change the autogenerated stub
            DB::commit();
            return true;
        }catch (Exception $e){
            DB::rollBack();
            return false;
        }
    }
}
